<%@page import="com.is.control.ParamClassControl"%>
<%@page import="com.is.control.CourseClassControl"%>
<%@page import="com.is.model.CourseClass"%>
<%@page import="com.is.model.User"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.util.List"%>
<%@page import="com.is.model.Student"%>
<%@page import="com.is.control.StudentControl"%>
<%@page import="com.is.util.ParamUtil"%>
<%@page import="com.is.control.HomeworkControl"%>
<%@page import="com.is.control.ParamStuyearControl"%>
<%@page import="com.is.control.ParamCourseControl"%>
<%@page import="com.is.control.HomeworkTimeControl"%>
<%@page import="com.is.util.DesData"%>
<%@page import="com.is.util.DateTime"%>
<%@page import="com.is.model.ParamStuyear"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="/InterStu/resources/image/favicon.ico" />
<link rel="stylesheet" type="text/css" href="../../resources/css/all.css" />
<script type="text/javascript" src="../../resources/js/jquery-1.8.1.js"></script>
<script type="text/javascript" src="../../resources/js/WebCalendar.js"></script>
<link href="../../resources/css/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../resources/js/jquery.artDialog.js"></script>
<script type="text/javascript" src="../../resources/js/iframeTools.js"></script>
<script type="text/javascript">
	$(function(){
		var block = $("#magic_block");
		if($(".active a").position()){
			block.css("top",$(".active a").position().top+10)
			.data("oriTop",$(".active a").position().top)
		}
		$(".nav ul li").find("a").hover(
			function(){
				var $this = $(this);
				var newTop = $this.position().top;
				block.stop().animate({
					top:newTop+10
				})
			},
			function(){
				block.stop().animate({
					top:block.data("oriTop")+10
				})
			}
		)
		$(".allCourses").click(function(){
			var url = $(this).attr("rel");
			$.dialog.open(url,{width:460,height:'auto'});
		})
		var h = $(".right").height();
		$(".left").height(h);
		$(".update").click(function(){
			$.dialog.open("/InterStu/update_info.jsp",{width:460,height:400,title:"个人信息"});
		})
		$('img').error(function(){
			this.src = "/InterStu/resources/image/man.GIF";
		})
		$("[name='stuyear']").change(function(){
			var selectYear = $(this).val();
			$.ajax({
				type:"post",
				dataType:"html",
				url:"select_option.jsp",
				data:{
					stuYearId:selectYear
				},
				cache:false,
				success:function(data){
					$("[name='ccid']")[0].options.length = 0;
					$("[name='ccid']").append(data);
				}
			})
		})
	})
	function doSubmit(){
      var submit = document.getElementById("submit");
      submit.disabled="disabled";
      return true;
}

	
</script>
<title>留学生预科班</title>
</head>
<body>
<%	User cu = (User)session.getAttribute("user");
%>
<div class="header">
	<div class="title pr">
    	<a href="javascript:void(0);"><span class="update pa">个人信息</span></a>
        <span class="logout pa"><a class="hide" href="/InterStu/login/logout.jsp">退出</a></span>
    </div>
</div>
<div class="main">
	<div class="left">  
		<div class="infomation">
			<div class="photo">
			<%
			String picUrl = cu.getPicUrl();
			%>
				<img width='60' height="60" src = "<%=picUrl %>" />
			</div>
			<div class="welcome">
				<%=cu.getName() %>,<br/>
				欢迎您使用！
			</div>
		</div>    	
    	<div class="nav">
        	<ul>	
        		<li class="pa" id="magic_block"></li>
            	<%if(cu!=null&&cu.getRole().equals("1")){ %>
                <li><a href="/InterStu/pages/stuyear/stuyear_start.jsp">新学期设置</a></li>
                <li><a href="/InterStu/pages/users/user_all.jsp">用户管理</a></li>
                <%} %>
                <li><a href="/InterStu/pages/students/student_add.jsp">学生管理</a></li>
                <li class="active"><a href="/InterStu/pages/dictation/dictation_add.jsp">学生考核</a></li>
                <%if(cu!=null&&cu.getRole().equals("1")){ %>
                <li><a href="/InterStu/pages/assess/teacher_assess.jsp">教职人员管理</a></li>
                <%} %>
            </ul>
        </div>
    </div>
    <div class="right">
    	<div class="r1">
    	<table class="dictations tab">
	    <tr>
	    	<td>
	    		<a href="/InterStu/pages/dictation/dictation_add.jsp">听写成绩</a>
			</td>
			<td>
				<a class="current" href="/InterStu/pages/homework/homework_add.jsp">作业成绩</a>			
			</td>
			<td>
				<a href="/InterStu/pages/courseScore/score_go.jsp">成绩录入</a>
			</td>
			<%if(cu!=null&&cu.getRole().equals("1")){ %>
			<td>
				<a href="/InterStu/pages/evaluation/students_all.jsp">综合评价</a>
			</td>
			<%} %>
	    </tr>
	    </table>
<%
	DesData des = new DesData();
	int courseClassId = Integer.parseInt(des.decrypt(ParamUtil.getString(request,"ccid","4d3d3f222d4c6e08")));//默认为0
	String time1 = DateTime.SimpleDate();
	 String time2 = DateTime.SimpleDate();
	   int stuyear = ParamStuyearControl.getCurrentStuyearId();
	   int usingStuyear = ParamUtil.getInt(request,"stuyear",stuyear);
	   session.setAttribute("stuYearId",usingStuyear);
	  // System.out.println("ddd" + session.getAttribute("stuYearId"));
	   ParamStuyear usingPS = ParamStuyearControl.getStuyear(usingStuyear);
	   if(stuyear!=0&&usingPS!=null){
	        time1 = ParamUtil.getString(request,"time1",usingPS.getStartTime());//默认为本学期开学时间
	     }
	   if(stuyear==usingStuyear){
	        time2 = ParamUtil.getString(request,"time2",DateTime.SimpleDate());
	   }else{
		    time2 = usingPS.getEndTime();
	   }
	   //System.out.println(time1 + "dd" + time2);
	List<CourseClass> ccs = null;
	int stuYear = (Integer)session.getAttribute("stuYearId");
	if(cu!=null&&cu.getRole().equals("1")){
		   //管理员应该能查看所有的课程班级出勤情况
		  ccs = CourseClassControl.getAllCourseClassIdByUidAndStuyear(0,stuYear);
	}
	if(cu!=null&&cu.getRole().equals("0")){
		   //任课教师看到自己所带课程的出勤情况
		   ccs = CourseClassControl.getAllCourseClassIdByUidAndStuyear(cu.getId(),stuYear);
	}
	if(ccs==null||ccs.size()==0){
		   out.print("本学期尚未有任何课程教学工作。");
	}else{
	%>
	   <form action="homework_statistics.jsp" method="post">
	   <table class="table">
	   <tr>
	   <td>学期</td>
	   <td>
	   		<select name="stuyear" style="width:100px;">
		   <%
		    List<ParamStuyear> stuyears = ParamStuyearControl.getAllStuyear();
		     for(ParamStuyear ps:stuyears){
		    	 %>
		    	 <option value="<%=ps.getId() %>"  <%if(ps.getId()==stuyear)out.print("selected"); %>><%=ps.getStuyear() %></option>
		    	 <%
		     }
		   %>
		   </select>
	   </td>
	   <td>
	   <select name="ccid" style="width:100px;">
	   <%
	      for(CourseClass cc:ccs){
	   %>
	   <option value="<%=des.encrypt(cc.getId()+"") %>" <%if(cc.getId()==courseClassId) out.print("selected='selected'");%>><%=ParamClassControl.getClassName(cc.getClassId()) %>&<%=ParamCourseControl.getCourseById(cc.getCourseId()).getCourseName() %></option>
	   <%} %>
	   </select>		
	   </td>
				<td>开始时间</td>
				<td><input id="time1" type='text'  name="time1" onclick="SelectDate(this,'','','yyyy-MM-dd')"  readonly style="cursor:pointer"  value="<%=time1 %>"/></td>
		        <td>结束时间</td>
				<td><input id="time2" type='text'  name="time2" onclick="SelectDate(this,'','','yyyy-MM-dd')"  readonly style="cursor:pointer"  value="<%=time2 %>"/></td>
		        <td><input type="submit" value="确定"/>
		        </td>
		</tr>
	</table>
	   </form>
	   <%
   }

%>
<%
    if(courseClassId>0){
    	CourseClass cc = CourseClassControl.getCourseClassById(courseClassId);
    	String courseName = ParamCourseControl.getCourseById(cc.getCourseId()).getCourseName();
    	String className = ParamClassControl.getClassName(cc.getClassId());
   
 %>
 <div class="r2">
 <form>
<table class="table">
<caption><%=className %><%=courseName %>此期间内已经布置作业<%=HomeworkTimeControl.getCount(courseClassId,ParamStuyearControl.getCurrentStuyearId(),time1,time2) %>次。 
</caption>
<thead>
<tr>
	<th>姓名</th>
	<th>A</th>
	<th>B</th>
	<th>C</th>
	<th>D</th>
</tr>
</thead>
<tbody>

<%
     List<Student> students = StudentControl.getAllStudentMulti("","","",String.valueOf(cc.getClassId()),"","","","");
     for(Student s:students){
    	 
     %>
     <tr>
     <td><a class="allCourses" href="javascript:void(0);" rel="allCoursesOneStu.jsp?stuId=<%=des.encrypt(String.valueOf(s.getId())) %>"><%=s.getChineseName() %></a></td>
     <td><%=HomeworkControl.getCount(s.getId(),"A",courseClassId,ParamStuyearControl.getCurrentStuyearId(),time1,time2) %></td>
     <td><%=HomeworkControl.getCount(s.getId(),"B",courseClassId,ParamStuyearControl.getCurrentStuyearId(),time1,time2) %></td>
     <td><%=HomeworkControl.getCount(s.getId(),"C",courseClassId,ParamStuyearControl.getCurrentStuyearId(),time1,time2) %></td>
     <td><%=HomeworkControl.getCount(s.getId(),"D",courseClassId,ParamStuyearControl.getCurrentStuyearId(),time1,time2) %></td>
     </tr>
     <%
     }
 %>
 </tbody>
</table>
</form>
<%}else{} %>
</div>
</div>
</div>
</div>
<div class="footer">
	<p>版权所有：东北师范大学留学生预科部&nbsp;&nbsp;  蓝旭工作室开发</p>
</div>
</body>
</html>